import socket
#TCP连接
with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s:
    s.bind(('localhost',12345))
    s.listen()
    conn,addr=s.accept()
    with conn:
        print('Connected by',addr)
        conn.sendall(b'Hello Client')

#UDP连接
print('-'*40)

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
    s.bind(('localhost', 12345))
    data, addr = s.recvfrom(1024)
    s.sendto(b'Hello, client!', addr)